part of 'cell.dart';
@deprecated
class HorizontalLabelCell extends StatelessWidget {
  final Widget? title;
  final Widget? subTitle;
  final Widget? rightWidget;
  final Widget? leftWidget;
  final bool? isShowBottomLine;
  final double? verticalSpacing;
  final double? horizontalSpacing;
  final EdgeInsetsGeometry? padding;
  final EdgeInsetsGeometry? margin;
  final GestureTapCallback? onTap;
  final Color? background;
  final Color? bottomLineColor;
  final double? bottomLineWidth;
  final TextAlign textAlign;
  final bool enable;
  final bool? isAlignTop;

  const HorizontalLabelCell({
    super.key,
    this.title,
    this.subTitle,
    this.rightWidget,
    this.isShowBottomLine,
    this.verticalSpacing,
    this.padding,
    this.horizontalSpacing,
    this.onTap,
    this.margin,
    this.background,
    this.leftWidget,
    this.textAlign = TextAlign.end,
    this.bottomLineColor,
    this.bottomLineWidth,
    this.enable = true,
    this.isAlignTop = false,
  });

  HorizontalLabelCell.title({super.key,
    String? title,
    String? subTitle,
    String? hint,
    TextStyle titleStyle = const TextStyle(fontSize: 16.0, color: Colors.black),
    TextStyle subTitleStyle = const TextStyle(fontSize: 14.0, color: Colors.blueGrey),
    TextStyle hintStyle = const TextStyle(fontSize: 14.0, color: Colors.grey),
    double? titleWidth,
    this.rightWidget,
    this.isShowBottomLine = false,
    this.verticalSpacing,
    this.padding,
    this.horizontalSpacing,
    bool isMust = false,
    this.onTap,
    this.margin,
    this.background,
    this.leftWidget,
    this.textAlign = TextAlign.end,
    this.bottomLineColor,
    this.enable = true,
    this.isAlignTop = false,
    this.bottomLineWidth})
      : this.title = Container(
      width: titleWidth,
      child: Text.rich(
        TextSpan(text: '', style: titleStyle, children: [
          TextSpan(
            text: isMust ? ' * ' : '',
            style: titleStyle.copyWith(color: Colors.red),
          ),
          TextSpan(text: title)
        ]),
        maxLines: 1,
        overflow: TextOverflow.ellipsis,
      )),
        this.subTitle = Text(
          TextHelper.checkText(subTitle, defaultText: hint ?? ''),
          style: ObjectUtil.isEmpty(subTitle) ? hintStyle : subTitleStyle,
          maxLines: 2,
          textAlign: textAlign,
          overflow: TextOverflow.ellipsis,
        );

  HorizontalLabelCell.select({super.key,
    String? title,
    String? subTitle,
    String? hint,
    TextStyle titleStyle = const TextStyle(fontSize: 16.0, color: Colors.black),
    TextStyle subTitleStyle = const TextStyle(fontSize: 14.0, color: Colors.blueGrey),
    TextStyle hintStyle = const TextStyle(fontSize: 14.0, color: Colors.grey),
    double? titleWidth,
    this.isShowBottomLine = false,
    this.verticalSpacing,
    this.padding,
    this.horizontalSpacing,
    bool isMust = false,
    bool isShowArrow = true,
    this.onTap,
    this.margin,
    this.background,
    this.leftWidget,
    this.textAlign = TextAlign.end,
    this.bottomLineColor,
    this.enable = true,
    this.isAlignTop = false,
    this.bottomLineWidth})
      : this.title = Container(
      width: titleWidth,
      child: Text.rich(
        TextSpan(text: '', style: titleStyle, children: [
          TextSpan(
            text: isMust ? ' * ' : '',
            style: titleStyle.copyWith(color: Colors.red),
          ),
          TextSpan(text: title)
        ]),
        maxLines: 1,
        overflow: TextOverflow.ellipsis,
      )),
        this.subTitle = Text(
          TextHelper.checkText(subTitle, defaultText: hint ?? ''),
          style: ObjectUtil.isEmpty(subTitle) ? hintStyle : subTitleStyle,
          maxLines: 2,
          textAlign: textAlign,
          overflow: TextOverflow.ellipsis,
        ),
        this.rightWidget = Visibility(
            visible: isShowArrow,
            child: const Icon(
              Icons.arrow_forward_ios,
              size: 15,
            ));

  HorizontalLabelCell.edit({super.key,
    String? title,
    String? value,
    String? hint,
    TextStyle titleStyle = const TextStyle(fontSize: 16.0, color: Colors.black),
    TextStyle valueStyle = const TextStyle(fontSize: 14.0, color: Colors.blueGrey),
    TextStyle hintStyle = const TextStyle(fontSize: 14.0, color: Colors.grey),
    double? titleWidth,
    TextEditingController? controller,
    int maxLength = 200,
    this.isShowBottomLine = false,
    this.verticalSpacing,
    this.padding,
    this.horizontalSpacing,
    bool isMust = false,
    this.onTap,
    this.margin,
    this.background,
    this.rightWidget,
    this.leftWidget,
    this.textAlign = TextAlign.end,
    this.bottomLineColor,
    this.enable = true,
    this.isAlignTop = false,
    this.bottomLineWidth})
      : this.title = Container(
      width: titleWidth,
      child: Text.rich(
        TextSpan(text: '', style: titleStyle, children: [
          TextSpan(
            text: isMust ? ' *' : '',
            style: titleStyle.copyWith(color: Colors.red),
          ),
          TextSpan(text: title)
        ]),
        maxLines: 1,
        overflow: TextOverflow.ellipsis,
      )),
        this.subTitle = CupertinoTextField(
          controller: controller,
          style: Platform.isIOS ? valueStyle : valueStyle.copyWith(height: 1.2),
          placeholder: hint,
          placeholderStyle: hintStyle,
          textAlign: textAlign,
          decoration: const BoxDecoration(),
        );

  @override
  Widget build(BuildContext context) {
    return IgnorePointer(
      ignoring: !enable,
      child: GestureDetector(
        onTap: onTap,
        child: Container(
          padding: padding,
          margin: margin,
          decoration: BoxDecoration(
            color: background ?? Colors.transparent,
            border: Border(
              bottom: BorderSide(
                  color: isShowBottomLine! ? bottomLineColor ?? Colors.black.withOpacity(0.15) : Colors.transparent, width: bottomLineWidth ?? 0.5),
            ),
          ),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              leftWidget ?? Gaps.empty,
              Expanded(
                child: Row(
                  crossAxisAlignment: (isAlignTop ?? false) ? CrossAxisAlignment.start : CrossAxisAlignment.center,
                  children: [
                    title ?? Gaps.empty,
                    SizedBox(
                      width: horizontalSpacing ?? 0,
                    ),
                    Expanded(child: subTitle ?? Gaps.empty),
                  ],
                ),
              ),
              SizedBox(
                width: horizontalSpacing ?? 0,
              ),
              rightWidget ?? Gaps.empty,
            ],
          ),
        ),
      ),
    );
  }
}
